/**
 * 
 */
package fr.castorhoz.isi_connectivity_widget.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import android.widget.Toast;

/**
 * @author hozakan
 *
 */
public class DataBaseHelper extends SQLiteOpenHelper
{
	Context	context;
	
	public DataBaseHelper(Context context) 
	{
		super(context, "isi-connectivity-widget", null, 1);
		this.context = context;
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		Log.i(DataBaseHelper.class.toString(), "onCreate method called");
		Log.println(Log.INFO, DataBaseHelper.class.toString(), "onCreate method called");
		db.execSQL("create table appWidgetContent (_id integer primary key autoincrement, "
				+ "widgetName text not null"
				+ ");");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
	{
		Toast.makeText(context, "Mise à jour de la Base de données version "+oldVersion+" vers "+newVersion, Toast.LENGTH_SHORT).show();
		db.execSQL("DROP TABLE IF EXISTS appWidgetContent");
		onCreate(db);
	}
	
}

